<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../layui/css/layui.css">

</head>
<body>
<table id="userTable" lay-filter="test"></table>
</body>
<script src="../layui/layui.js"></script>
<script>
//Demo
layui.use('table', function(){
  var table = layui.table;

  //第一个实例
  table.render({
    elem: '#userTable'
    ,url: '/myBalsamiqProject/insect.do' //数据接口
    //,page: true //开启分页
    ,parseData: function(res){ //res 即为原始返回的数据
      return {
        "code": 0, //解析接口状态
        "count": res.length, //解析数据长度
        "data": res
      };
    }
    ,cols: [[ //表头
      {field: 'name', title: '虫',sort: true, fixed: 'left'}
      ,{field: 'host', title: '寄主'}
      ,{field: 'harm', title: '危害',  sort: true}
    ]]
  });
});
</script>
</html>